/** 
 * 标示集合 
 */
var marking = {
    globalPath: "http://dccs.lenovo.com.cn/",
    CookieShareId: "",
    wxJs: null,
    pageIdentiy: {
        source: "",
        shareId: "",
        newRedReceiveStatus: "",
        score: "",
        attenStatus: "",
        nickName: "",
        myself: ""
    }
};
/**
 * 微信授权
 */
if (!isWeiXin()) {
    alert('跳转其他页面');
    //window.location.href='';
} else {
    var deviceId = operateCookie.getCookie("fenli_deviceID");
    var CookieShareId = operateCookie.getCookie("fenli_shareID");
    marking.CookieShareId = CookieShareId;
    var source = unescape(getParameter("source"));
    marking.pageIdentiy.source = source;
    marking.pageIdentiy.shareId = unescape(getParameter("shareId"));


    //判断是否存在cookie，如果不存在则去授权
    if (deviceId == null || deviceId == "" || source == "" || marking.pageIdentiy.shareId == "") {
        if (source == "") {
            alert("source为空");
            window.location.href = marking.globalPath + "/v1/lenovo/card/lucky2018.do";
        } else {
            if (marking.pageIdentiy.shareId == "") {
                alert("shareId为空");
                window.location.href = marking.globalPath + "/v1/lenovo/card/lucky2018.do?source=" + source;
            } else {
                alert("shareId不为空");
                window.location.href = marking.globalPath + "/v1/lenovo/card/lucky2018.do?source=" + source + "&shareId=" + marking.pageIdentiy.shareId;
            }
        }
    } else {
        //获取用户标示
        $.ajax({
            url: marking.globalPath + "/v1/lenovo/lucky2018/validateUser.do",
            type: "post",
            dataType: "jsonp",
            data: {
                shareId: marking.pageIdentiy.shareId
            },
            success: function (data) {
                if (data.result == "ok") {
                    //向当前数据集中添加数据
                    marking.newRedReceiveStatus = data.values.newRedReceiveStatus;
                    marking.score = data.values.score;
                    marking.attenStatus = data.values.attenStatus;
                    marking.nickName = data.values.nickName;
                    marking.myself = data.values.myself;
                    alert("nickName:" + self.nickName);
                    alert("myself:" + marking.myself);
                    //获取用户表示成功后调用浏览记录接口
                    marking.trackUrl();
                    marking.saveShareAccessRecord();
                    alert.log(marking);
                } else {
                    if (data.values == "userNull") {
                        window.location.href = marking.globalPath + "/v1/lenovo/card/lucky2018.do";
                    }
                }
            }
        });

    }
}